package com.iSnail.ms.util;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.apache.log4j.Logger;

public final class I18N {
	private final static ResourceBundle rb = ResourceBundle.getBundle(Const.APP_NAME);
	private final static Logger log = Logger.getLogger(I18N.class.getName());

	public static String getString(String key) {
		try {
			return rb.getString(key);
		} catch (MissingResourceException e) {
			log.info("getString failed:", e);
		}
		return key;
	}

	public static String getString(String key, Object[] args) {
		try {
			String temp = rb.getString(key);
			return MessageFormat.format(temp, args);
		} catch (MissingResourceException e) {
			log.info("getString failed:", e);
		}
		return key;
	}

	public static void main(String[] args) {
		System.out.println(getString("app_name"));
	}
}